/*
 * Copyright (c) 2010 Sylvestre Gallon <syl@pmbsd.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef __CLASS_H__
#define __CLASS_H__

typedef struct objc_class *MetaClass;
typedef struct objc_class *Class;

struct objc_ivar_list;
struct objc_method_list;
struct objc_dispatch_list;
struct objc_protocol_list;

struct objc_class {
        MetaClass meta;
        Class super;

        const char *name;
        long version;
        unsigned info;

        long instance_size;

        struct objc_ivar_list *ivars;
        struct objc_method_list *methods;
        struct objc_dispatch_list *dtable;

        Class subclass_list;
        Class sibling_class;

        struct objc_protocol_list *protocols;
        void *gc_object_type;
};

typedef struct objc_super {
	id self;
	Class cl;
} *Super;

struct class_hash {
        Class cl;
        TAILQ_ENTRY(class_hash) entry;
};

TAILQ_HEAD(class_hash_head, class_hash);

Class objc_lookup_class(const char *name);
Class objc_get_class(const char *name);
void __objc_add_class_in_hash(Class cl);
void __objc_init_class_hash(void);
id __objc_class_create_instance(Class cl);
id __objc_class_object_dispose(id obj);

#endif /*__CLASS_H__*/

